﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace _015_线程_任务
{
    class Program
    {
        static void Main(string[] args)
        {
            // 第一种
            Task t = new Task(() =>
            {
                Console.WriteLine("任务开始");
                Thread.Sleep(2000);
                Console.WriteLine("任务结束");
            });
            t.Start();

            // 第二种
            TaskFactory tf = new TaskFactory();
            Task<string> t3 = new Task<string>(()=> "415661");
            t3.Start();
            string res = t3.Result;

            Task t2 = tf.StartNew(() =>
            {
                Console.WriteLine("任务开始");
                Thread.Sleep(2000);
                Console.WriteLine("任务结束");
            });
            t2.Start();
            t2.
            Console.ReadKey();
        }
    }
}
